package main

import (
	"fmt"
	"time"

	"gitee.com/git-lz/zk-elect-master/xzk"
)

func main() {
	xzk.Init(&xzk.Config{
		Servers:     []string{"127.0.0.1:2181"},
		ConnTimeout: time.Second * 5,
	})

	isMasterChan := make(chan bool)

	electM := xzk.NewElectionManager(isMasterChan, "/demoServer", "/demoMaster")
	go electM.Run()

	for {
		select {
		case isMaster := <-isMasterChan:
			if isMaster {
				fmt.Println("do master job...")
			}
		}
	}
}
